package com.mars.ticket.config;

public class Main {

    public static void main(String[] args) {
        printCircle(2);
        //printSquare(10);
    }

    public static void printSquare(int len) {
        StringBuilder oneLine = new StringBuilder();
        for (int i = 0; i < len; i++) {
            oneLine.append("X ");
        }
        oneLine.append("\n");
        int e = Math.max(len - 2, 0);
        StringBuilder eLine = new StringBuilder("X ");
        for (int i = 0; i < e; i++) {
            eLine.append("  ");
        }
        eLine.append("X\n");
        StringBuilder result = new StringBuilder(oneLine);
        for (int i = 0; i < e; i++) {
            result.append(eLine);
        }
        result.append(oneLine).append("\n");
        System.out.println(result);
    }


    public static void printCircle(double r) {
        r = r + 2;
        double R = 2 * r;
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i <= R; i += 2) {
            double y = i <= r ? r - i : i - r;
            double len = Math.round(Math.sqrt(r * r - y * y));
            for (int j = 0; j < r - len; j++) {
                sb.append(" ");
            }
            sb.append("XX");
            for (int j = 0; j < 2 * len; j++) {
                sb.append(" ");
            }
            sb.append("XX\n");
        }
        System.out.println(sb);
    }

}
